package com.gxa.shop.servlet.order; /**
 * ${PACKAGE_NAME}
 * User: coma
 * Description:
 * Version: V1.0
 */

import com.alibaba.fastjson.JSON;
import com.gxa.shop.bean.pojo.Orders;
import com.gxa.shop.commons.r.R;
import com.gxa.shop.service.order.OrderService;
import com.gxa.shop.service.order.impl.OrderServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet(name = "findOrdersServlet", value = "/member/order/payback")
public class findOrdersServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("application/json;charset=UTF-8");
        OrderService orderService = new OrderServiceImpl();
        R r;
        String id = request.getParameter("orderId");
        Integer orderId=Integer.parseInt(id);
        List<Orders> list=orderService.getOrders(orderId);
        r=list==null? R.ok("没有订单"):R.ok(list);
        PrintWriter writer = response.getWriter();
        String  result= JSON.toJSONString(r);
        writer.write(result);
        writer.flush();
        writer.close();

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
